﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <title></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
    	div.box-body {
    		margin-top:7px;
    	}
    </style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
    </section>
    <section class="content">
         <form  class="form-horizontal" action="compGroupList.jsp" method="post"> 
                   <input type="hidden" id="groupId" value="${scg.compGroupId }">
                   <input type="hidden" id="sta" value="${scg.status }">  
        <div class=" box box-success">
            <!-- form start -->
                <div class="box-body">
                    <div class="form-group form-group-xs margintop-xs">
                        <label class="col-sm-2 text-right"><span style="color:red">* </span><spring:message code="message.listForm.jiTuanBianMa"/>：</label>
                        <div class="col-sm-9 text-left">
                            <input class="form-control" placeholder="<spring:message code="message.listForm.jiTuanBianMa"/>" type="text" value="${scg.compGroupCode }" id="groupCode" maxlength="36">
                        </div>

                    </div>
                    <div class="form-group form-group-xs margintop-xs">
                        <label class="col-sm-2 text-right"><span style="color:red">* </span><spring:message code="message.listForm.jiTuanMingCheng"/>：</label>
                        <div class="col-sm-9 text-left">
                            <input class=" form-control" placeholder="<spring:message code="message.listForm.jiTuanMingCheng"/>" type="text" value="${scg.compGroupName }" id="groupName" maxlength="170">
                        </div>
                    </div>
                    <div class="form-group form-group-xs margintop-xs">
                        <label class="col-sm-2 text-right"><span style="color:red">* </span><spring:message code="message.listForm.jiTuanJianCheng"/>：</label>
                        <div class="col-sm-9 text-left">
                            <input class=" form-control" placeholder="<spring:message code="message.listForm.jiTuanJianCheng"/>" type="text" value="${scg.compGroupShortname }" id="groupShortname" maxlength="85">
                        </div>
                   </div>
           
   
                    <div class="form-group form-group-xs margintop-xs">
                        <label class="col-sm-2 control-label"><spring:message code="message.lable.remark"/>：</label>
                        <div class="col-sm-9">
                        <textarea class="form-control" rows="" placeholder="<spring:message code="message.lable.remark"/>" id="remark" cols="" maxlength="341">${scg.remark }</textarea>
                        </div>
                    </div>
                </div>
                 <div class="box-footer text-center">
                    <button type="button" onclick="save();" class="btn btn-success btn-sm"><spring:message code="message.button.saveSpacing"/></button>
                </div>     
            
        </div>
       </form> 
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
	//保存
    function save(){
  				 var groupId=$.trim($('#groupId').val());
  				var groupCode=$.trim($('#groupCode').val());
  				var groupName=$.trim($('#groupName').val());
  				var groupShortname=$.trim($('#groupShortname').val());
  				var remark=$.trim($('#remark').val());
  				var sta=$.trim($('#sta').val()); 
  				

  				if(groupCode==""){
                    $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.jiTuanBianMa"/>", "warn");
                    return ;
                 }else if (!/^\d+$/.test(groupCode)) {
                     $.alert("<spring:message code="message.listForm.jiTuanBianMa"/><spring:message code="message.yanZheng.zhiNengYouZiMuShuZiZuCheng"/>", "warn");
                     return  false;
                 }else if (groupCode.length>36){
                     $.alert("<spring:message code="message.listForm.jiTuanBianMa"/><spring:message code="message.info.zuiDaChangDu"/>36<spring:message code="message.info.geZiFu"/>", "warn");
                     return  false;
                 }
                
                
               groupName=$.trim($('#groupName').val()); 
               if(groupName==""){
                    $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.jiTuanMingCheng"/>", "warn");
                    return ;
               }else if (groupName.length>170){
                   $.alert("<spring:message code="message.listForm.jiTuanMingCheng"/><spring:message code="message.info.zuiDaChangDu"/>170<spring:message code="message.info.geZiFu"/>", "warn");
                   return  false;
               }
               
               
               groupShortname=$.trim($('#groupShortname').val());
               if(groupShortname==""){
                    $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.jiTuanJianCheng"/>", "warn");
                    return ;
               }else if (groupShortname.length>85){
                   $.alert("<spring:message code="message.listForm.jiTuanJianCheng"/><spring:message code="message.info.zuiDaChangDu"/>85<spring:message code="message.info.geZiFu"/>", "warn");
                   return  false;
               }
			   
			 remark = $.trim($("#remark").val());
            if (remark == null || remark == "") {
                
            }else if(remark.length>341){
                $("#remark").trigger("focus");
                $.alert("<spring:message code="message.lable.remark"/><spring:message code="message.info.zuiDaChangDu"/>341<spring:message code="message.info.geZiFu"/>！", "warn");
                return false;;
            } 
			   
               
  	  $.HN.message.confirm('<spring:message code="message.HN.alert.OkSaveYESorNO"/>', '', '').on(
  			function (e) {      
            if (e) {
            	
            	$.ajax({
					type:"POST",
					url:"submitStdCompGroup.html",
					data:{"compGroupId":groupId,"compGroupCode":groupCode,"compGroupName":groupName,"compGroupShortname":groupShortname,"remark":remark,"status":sta},
					dataType:"json",
					success:function(returnData){
						if(returnData.success){
							$.alert("<spring:message code="message.HN.alert.baoCunCheng"/>", "success");
							window.top.dialog({id:'edit'}).close();
							var page = top.mainframe.currentPage();
							top.mainframe.search(page); 
						}else{
							if(returnData.msg==1){
								$.alert("<spring:message code="message.listForm.jiTuanBianMa"/><spring:message code="message.lable.yiChunZai"/>", "error");
							}else if(returnData.msg==2){
								$.alert("<spring:message code="message.listForm.jiTuanMingCheng"/><spring:message code="message.lable.yiChunZai"/>",  "error");
							}else{
								$.alert(returnData.msg || "<spring:message code="message.HN.alert.baoCunBai"/>", "error");
							}
						}
					}
				});
                
            }
        });
  	  
    }
    

     function back(){
     	window.location.href="compGroupList.html";
     }
   
     
   
     
    </script>
</body>
</html>
